package com.dgut.demo.service.impl;

import com.dgut.demo.bean.HandlersMessage;
import com.dgut.demo.bean.VipMessage;
import com.dgut.demo.controller.LogsController;
import com.dgut.demo.mapper.HandlersMapper;
import com.dgut.demo.service.HandlersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther 虎
 * @Data 2021/2/16 15:59
 * @Version 1.0
 */
@Service
public class HandlersServiceImpl implements HandlersService {
    @Autowired
    private HandlersMapper handlersMapper;
    @Autowired
    private LogsController logsController;

    @Override
    public HandlersMessage getOneHandlersMessage(String username) {
        return handlersMapper.getOneHandlersMessage(username);
    }

    @Override
    public int updateHandlerPassword(String heid, String passwords1, String passwords) {
        String passwords2 = handlersMapper.getPasswordById(heid);
        if(passwords2.equals(passwords1)){
            //log
            String actions = "成功更改密码";
            String userId = heid;
            logsController.addOneLogsMessage(actions,userId);

            return handlersMapper.updateHandlerPassword(heid,passwords);
        }else {
            return 4;
        }
    }
}
